package cn.edu.buaa.neo.query.cxx.misuse.outdateProblem;

import cn.edu.buaa.neo.codegraphql.core.graph.values.statements.expressions.CallExpression;
import cn.edu.buaa.neo.codegraphql.core.graph.values.statements.expressions.Literal;
import cn.edu.buaa.neo.codegraphql.dsl.lib.engine.QueryEngine;
import cn.edu.buaa.neo.codegraphql.dsl.fluent.query.QueryDescriptor;
import cn.edu.buaa.neo.codegraphql.language.cxx.CxxQuery;

import java.io.PrintStream;

public class Encrypt3DES extends CxxQuery {
    public static void main(String[] args) {
        QueryEngine.getInstance()
                .execute(Encrypt3DES.class.getSimpleName(), new Encrypt3DES())
                .close();
    }

    @Override
    public void run(String style, PrintStream output) {
        QueryDescriptor.open()
                .from("source", v -> v.toStream().anyMatch(
                        call -> call instanceof CallExpression expression &&
                                expression.getArgumentsSize() >= 2 &&
                                expression.getArgumentAt(1) instanceof Literal literal &&
                                "CALG_3DES".equals(literal.getValue())))
                .select("source")
                .display();
    }
}
